package com.gxar.quick.ar.server.base.async.exchange.listener;

import com.gxar.quick.ar.server.base.async.exchange.event.AutoExchangeEvent;
import com.gxar.quick.ar.server.base.facade.ExchangeItemFacade;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @author linsy
 * @version 1.0
 * @created 2024/4/18 09:16
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class AutoExchangeListener implements ApplicationListener<AutoExchangeEvent> {

    private final ExchangeItemFacade exchangeItemFacade;

    @Override
    @Async("autoExchangeThreadPool")
    public void onApplicationEvent(AutoExchangeEvent event) {
        exchangeItemFacade.exchange(event.getUserProfile(), event.getCode());
    }

}
